//  Masaaki Higashijima & Austin M. Mitchell. "Democracy and State Development." 
// Comparative Political Studies 
// Replication file
// 09-12-2024



////////////////////////////////////

* Figure 1

use "CPS_HM2024_replication.dta", clear

egen v5_security_p_mean = mean(v5_security_p), by(year) 
egen v5_admin_p_mean = mean(v5_admin_p), by(year) 
egen v5_development_p_mean = mean(v5_development_p), by(year) 
egen v5_social_p_mean = mean(v5_social_p), by(year) 


graph twoway ///
/// Scatterplots
(scatter v5_security_p_mean year if cow==2000, mcolor(red*0.5) msize(vsmall) msymbol(square)) ///
(scatter v5_admin_p_mean year if cow==2000, mcolor(purple*0.5) msize(vsmall) msymbol(triangle)) ///
(scatter v5_development_p_mean year if cow==2000, mcolor(dkgreen*0.5) msize(vsmall) msymbol(diamond)) ///
(scatter v5_social_p_mean year if cow==2000, mcolor(blue*0.5) msize(vsmall) msymbol(circle)) ///
/// Line plots
(lowess v5_security_p_mean year if cow==2000, lcolor(red) lpattern(dash) lwidth(thick) text(55 1825 "Security", color(red) size(medium)) )  || ///
(lowess v5_admin_p_mean year if cow==2000, lcolor(purple) lpattern("--__") lwidth(thick) text(10 1825 "Administration", color(purple) size(medium)) )  || ///
(lowess v5_development_p_mean year if cow==2000, lcolor(dkgreen) lpattern(shortdash) lwidth(thick) text(10 1900 "Development", color(dkgreen) size(medium)) )  || ///
(lowess v5_social_p_mean year if cow==2000, lcolor(blue) lpattern(solid) lwidth(thick) text(5 1960 "Social", color(blue) size(medium))) , ///
 legend(off) xlabel(1800(25)1975, nogrid) ylabel(,nogrid) xtitle(Year) ytitle("Proportions of Spending (% of Budget)")

 drop if cow == 2000 // placeholder for creating Figure 1.

* Figure 2

use "V-Dem-CY-Full+Others-v14.dta", clear
egen part_ymean = mean(v2x_suffr), by(year)  
graph twoway line part_ymean year if cow==2 & year>=1800 & year < 1976, ytitle("Share of Population with Suffrage (Mean)") lcolor(red) xlabel(1800(25)1975) ylabel(,angle(0)) graphregion(color(white)) bgcolor(white)


* Figure 3

use "CPS_HM2024_replication.dta", clear
graph twoway (lfit comp_mpi part) (scatter comp_mpi part, mcolor(red%50) msize(small)), xtitle("Share of Population with Suffrage") ytitle("Contestation") legend(off) ylabel(,angle(0)) graphregion(color(white)) bgcolor(white) 


////// Main results


* Model 1: security 

xtreg v5_security_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop log_total_oil_income_pc e_miinterc e_miinteco i.year if cow != 40 & colony != 1, fe cluster(cow) 

est store main_sec

	
* Figure 4a

margins,  dydx(comp_mpi) at(part=(0(0.1)1)) atmeans
marginsplot,  recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Security share of spending", size(large))  level(95)  xtitle("Participation", size(large)) ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram part if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off)) graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)

* Figure 4b

margins,  dydx(part) at(comp_mpi=(0(0.1)1)) atmeans
marginsplot,  recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Security share of spending", size(large))  level(95)  xtitle("Contestation", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
 addplot(histogram comp_mpi if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2)) ylabel(none, axis(2)) legend(off)) graphregion(color(white)) bgcolor(white) 
 gr_edit yaxis2.draw_view.setstyle, style(no)

* Model 2: Admin

xtreg v5_admin_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco i.year if cow != 40 & colony != 1, fe cluster(cow) 


* Figure 5a

margins,  dydx(comp_mpi) at(part=(0(0.1)1)) atmeans
marginsplot, xdimension(part) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Administration share of spending", size(large))  level(95)  xtitle("Participation", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
 addplot(histogram part if e(sample)==1, fcolor(none) lcolor(gs11)  yaxis(2) ytitle("", axis(2)) ylabel(none, axis(2)) legend(off)) graphregion(color(white)) bgcolor(white) 
 gr_edit yaxis2.draw_view.setstyle, style(no)

* Model 3: Development 

xtreg v5_development_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) 


* Figure 5b

margins,  dydx(comp_mpi) at(part=(0(0.1)1)) atmeans
marginsplot, xdimension(part) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Development share of spending", size(large))  level(95)  xtitle("Participation", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
 addplot(histogram part if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2)) ylabel(none, axis(2)) legend(off)) graphregion(color(white)) bgcolor(white) 
 gr_edit yaxis2.draw_view.setstyle, style(no)


* Model 4: Social 

xtreg v5_social_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) 

* Figure 6

margins,  dydx(part) at(comp_mpi=(0(0.1)1)) atmeans
marginsplot, xdimension(comp_mpi) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Social share of spending", size(large))  level(95)  xtitle("Contestation", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
 addplot(histogram comp_mpi if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2)) ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)


///////////////////////////////////////

/////////////////////////
/////// Appendix ////////
/////////////////////////

///// Appendix A: Political Institution Data 

* Figure A1
capture drop d_part
gen d_part = d.part

capture drop d_comp_mpi
gen d_comp_mpi = d.comp_mpi


scatter d_comp_mpi d_part if v5_security_p != . & d_comp_mpi >=0 & d_part >= 0, ytitle("Change in Contestation") xtitle("Change in Participation") ylabel(, angle(0)) graphregion(color(white)) bgcolor(white) 


* Figure A2


est restore main_sec

gen sample = e(sample)

// security
twoway line v5_security_p year if cow != 40 & colony != 1 & sample==1, by(country, note("") graphregion(color(white)) bgcolor(white)) xtitle("",) ytitle("")  xlabel(1800 1850 1900 1950) ///
ylabel(, angle(0)) xlabel(,nogrid) lcolor(navy) subtitle(, bcolor(white)) graphregion(color(white)) bgcolor(white)

// admin
twoway line v5_admin_p year if cow != 40 & colony != 1  & sample==1, by(country, note("") graphregion(color(white)) bgcolor(white)) xtitle("") ytitle("") xlabel(1800 1850 1900 1950) ///
ylabel(, angle(0)) xlabel(,nogrid) lcolor(navy) subtitle(, bcolor(white)) 

// development
twoway line v5_development_p year if cow != 40 & colony != 1  & sample==1, by(country, note("") graphregion(color(white)) bgcolor(white)) xtitle("") ytitle("")  xlabel(1800 1850 1900 1950) ///
ylabel(, angle(0)) xlabel(,nogrid) lcolor(navy) subtitle(, bcolor(white)) 

// social
twoway line v5_social_p year if cow != 40 & colony != 1  & sample==1, by(country, note("") graphregion(color(white)) bgcolor(white)) xtitle("") ytitle("")  xlabel(1800 1850 1900 1950) ///
ylabel(0(10)50, angle(0)) xlabel(,nogrid) lcolor(navy) subtitle(, bcolor(white)) 

drop sample

///// Appendix B: Budget Allocation Data 

* Table B1 Sample of Countries


bysort country: sum year if e(sample) 

sort cow year

** Table  B2 Descriptive Statistics

est restor main_sec

summarize v5_security_p v5_admin_p v5_development_p v5_social_p v5_other_p comp_mpi part total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco if e(sample)==1

* Figure B1 Additional results

xtreg v5_admin_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco i.year if cow != 40 & colony != 1, fe cluster(cow) 

margins,  dydx(part) at(comp_mpi=(0(0.1)1)) atmeans
marginsplot, xdimension(comp_mpi) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Administration share of spending", size(large))  level(95)  xtitle("Contestation", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid)  ///
addplot(histogram comp_mpi if e(sample)==1, fcolor(none) lcolor(gs11)  yaxis(2) ytitle("", axis(2)) ylabel(none, axis(2)) legend(off)) graphregion(color(white)) bgcolor(white) 
 gr_edit yaxis2.draw_view.setstyle, style(no)

* Figure B2 

xtreg v5_development_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) 

margins,  dydx(part) at(comp_mpi=(0(0.1)1)) atmeans
marginsplot, xdimension(comp_mpi) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Development share of spending", size(large))  level(95)  xtitle("Contestation", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram comp_mpi if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2)) ylabel(none, axis(2)) legend(off)) graphregion(color(white)) bgcolor(white) 
 gr_edit yaxis2.draw_view.setstyle, style(no)


* Figure B3

xtreg v5_social_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) 

margins,  dydx(comp_mpi) at(part=(0(0.1)1)) atmeans
marginsplot, xdimension(part) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Social share of spending", size(large))  level(95)  xtitle("Participation", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
 addplot(histogram part if e(sample)==1, fcolor(none) lcolor(gs11)  yaxis(2) ytitle("", axis(2)) ylabel(none, axis(2)) legend(off)) graphregion(color(white)) bgcolor(white) 
 gr_edit yaxis2.draw_view.setstyle, style(no)

*** Appendix B5: Iterative model building for the appendix ***


foreach v in v5_security_p v5_admin_p v5_development_p v5_social_p {
local n = 0
local n = `n' + 1	
* model 1
xtreg `v' c.comp_mpi##c.part if cow != 40 & colony != 1, fe cluster(cow) 
est store `v'_`n'
local n = `n' + 1	

* model 2
xtreg `v' c.comp_mpi##c.part v5_other_p total_incl_l if cow != 40 & colony != 1, fe cluster(cow) 
est store `v'_`n'
local n = `n' + 1	

* model 3
xtreg `v' c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco  if cow != 40 & colony != 1, fe cluster(cow) 
est store `v'_`n'
local n = `n' + 1	

* model 4
xtreg `v' c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) 
est store `v'_`n'
}


///// Appendix C: Robustness Checks

*** Appendix C1: Multiple data imputation ***

use "CPS_HM2024_replication.dta", clear

drop if cow == 2000 // placeholder for creating Figure 1.

* set data set for MI
mi set wide
mi register imputed v5_security_p
mi register imputed v5_admin_p
mi register imputed v5_development_p
mi register imputed v5_social_p
mi register imputed v5_other_p
mi register imputed total_incl_l
mi register imputed deficit_p

* impute spending variables
mi impute mvn v5_security_p v5_admin_p v5_development_p v5_social_p v5_other_p total_incl_l deficit_p= comp_mpi part comp_part log_e_gdppc log_e_pop log_total_oil_income_pc e_miinterc e_miinteco, add(5) replace force rseed(1234)

summarize v5_security_p v5_admin_p v5_development_p v5_social_p v5_other_p total_incl_l deficit_p

* models with data imputation

* Table C1

* Model C-1
mi estimate, post : xtreg v5_security_p comp_mpi part comp_part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop log_total_oil_income_pc e_miinterc e_miinteco  i.year if colony !=1 & cow != 40, fe cluster(cow) 


* Model C-2
mi estimate, post : xtreg v5_admin_p comp_mpi part comp_part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop log_total_oil_income_pc e_miinterc e_miinteco  i.year if colony !=1 & cow != 40, fe cluster(cow) 


* Model C-3
mi estimate, post : xtreg v5_development_p comp_mpi part comp_part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop log_total_oil_income_pc e_miinterc e_miinteco  i.year if colony !=1 & cow != 40, fe cluster(cow) 


* Model C-4
mi estimate, post : xtreg v5_social_p comp_mpi part comp_part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop log_total_oil_income_pc e_miinterc e_miinteco  i.year if colony !=1 & cow != 40, fe cluster(cow) 


*** Appendix C2: Tobit Models ***

use "CPS_HM2024_replication.dta", clear

* Table C2

* Model C-5

tobit v5_security_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year i.cow if colony !=1 & cow != 40, vce(robust) ll ul

* Model C-6

tobit v5_admin_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year i.cow if colony !=1 & cow != 40, vce(robust) ll ul

* Model C-7

tobit v5_development_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year i.cow if colony !=1 & cow != 40, vce(robust) ll ul

* Model C-8

tobit v5_social_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year i.cow if colony !=1 & cow != 40, vce(robust) ll ul




*** Appendix C3: Categorical Measures of Political Regimes ***

*autocracies without elections

generate auto_wo_election = 0
replace auto_wo_election = 1 if e_lexical_index==0 & e_lexical_index!=4
replace auto_wo_election = . if e_lexical_index==.

generate lexical1_2 = 0
replace lexical1_2 = 1 if e_lexical_index==1 | e_lexical_index==2 
replace lexical1_2 = . if e_lexical_index==.

* closed autocracies

generate auto_closed = 0
replace auto_closed = 1 if lexical1_2==1 & e_lexical_index!=4
replace auto_closed = . if e_lexical_index==.

* autocracies without elections + closed 

generate auto_combined_wo_cl = 0
replace auto_combined_wo_cl = 1 if auto_wo_election==1 | auto_closed==1
replace auto_combined_wo_cl = . if e_lexical_index ==. // if auto_combined_wo_cl==.

*electoral autocracies

generate auto_elec = 0 
replace auto_elec = 1 if e_lexical_index==3 
replace auto_elec = . if e_lexical_index==. 

* competitive oligarchy 

generate olig_comp = 0 
replace olig_comp = 1 if e_lexical_index==4 | e_lexical_index==5
replace olig_comp = . if e_lexical_index==.

* competitive oligarchy (limited suffrage)

generate olig_comp2 = 0 
replace olig_comp2 = 1 if e_lexical_index==4 // | e_lexical_index==5
replace olig_comp2 = . if e_lexical_index==.

* electoral democracies

generate dem_elec = 0 
replace dem_elec = 1 if e_lexical_index==6
replace dem_elec = . if e_lexical_index==.

* electoral democracies (low suffrage threshold)

generate dem_elec2 = 0 
replace dem_elec2 = 1 if e_lexical_index==6 | e_lexical_index==5
replace dem_elec2 = . if e_lexical_index==.

* Model C-9: closed autocracies -- > security (security spending increases in closed autocracies compared to democracies)
xtreg v5_security_p auto_combined_wo_cl olig_comp auto_elec v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) 


* Model C-10: competitive olig -- > admin and developmnt (compared to closed auto) 

xtreg v5_admin_p olig_comp auto_elec dem_elec v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) 

* Model C-11

xtreg v5_admin_p olig_comp2 auto_elec dem_elec2 v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) // no difference between closed dictatorships with alternative measure

* Model C-12: development (development spending increases in competitive oligarchy compared to closed autocracies)  

xtreg v5_development_p olig_comp auto_elec dem_elec v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) 

* Model C-13

xtreg v5_development_p olig_comp2 auto_elec dem_elec2 v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow)  

* Model C-14: social (social spendiong increases in democracies compared to closed autocracies) 

xtreg v5_social_p dem_elec olig_comp auto_elec v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   i.year if cow != 40 & colony != 1, fe cluster(cow) 

use "CPS_HM2024_replication.dta", clear

*** Appendix C4: Conditional Effects of Social Classes *** 

// Three socioeconomic groups

// Landed elites
gen gr_rural =  v2regsupgroups_1 

// Urban elites
gen gr_urban = v2regsupgroups_10 

// Masses
gen gr_mass = v2regsupgroups_11 


// Triple interactions

* Security
xtreg v5_security_p c.comp_mpi##c.part##c.gr_rural c.comp_mpi##c.part##c.gr_urban c.comp_mpi##c.part##c.gr_mass  v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco i.year if cow != 40 & colony != 1, fe cluster(cow) 

est store sec_so2

margins,  at(gr_rural=(0(0.1)1) comp_mpi=0 part=0) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Security share of spending", size(large))  level(95)  xtitle("Support from landed elites", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_rural if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no) 


margins,  at(gr_rural=(0(0.1)1) comp_mpi=0.5 part=0.25) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Security share of spending", size(large))  level(95)  xtitle("Support from landed elites", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_rural if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no) 


margins,  at(gr_rural=(0(0.1)1) comp_mpi=1 part=1) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Security share of spending", size(large))  level(95)  xtitle("Support from landed elites", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_rural if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off)) graphregion(color(white)) bgcolor(white)  
gr_edit yaxis2.draw_view.setstyle, style(no)  

*Admin
xtreg v5_admin_p c.comp_mpi##c.part##c.gr_rural c.comp_mpi##c.part##c.gr_urban c.comp_mpi##c.part##c.gr_mass  v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco i.year if cow != 40 & colony != 1, fe cluster(cow) 

est store admin_so2

margins,  at(gr_urban=(0(0.1)1) comp_mpi=0 part=0.0) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) title("") ytitle("Administrative share of spending", size(large))  level(95)  xtitle("Support from urban middle class", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_urban if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  


margins,  at(gr_urban=(0(0.1)1) comp_mpi=0.5 part=0.25) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) title("") ytitle("Administrative share of spending", size(large))  level(95)  xtitle("Support from urban middle class", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_urban if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  


margins,  at(gr_urban=(0(0.1)1) comp_mpi=1 part=1) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) title("") ytitle("Administrative share of spending", size(large))  level(95)  xtitle("Support from urban middle class", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_urban if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  

*Development
xtreg v5_development_p c.comp_mpi##c.part##c.gr_rural c.comp_mpi##c.part##c.gr_urban c.comp_mpi##c.part##c.gr_mass v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco i.year if cow != 40 & colony != 1, fe cluster(cow) 

est store dev_so2

margins,  at(gr_urban=(0(0.1)1) comp_mpi=0 part=0.0) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) title("") ytitle("Development share of spending", size(large))  level(95)  xtitle("Support from urban middle class", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_urban if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  


margins,  at(gr_urban=(0(0.1)1) comp_mpi=0.5 part=0.25) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) title("") ytitle("Development share of spending", size(large))  level(95)  xtitle("Support from urban middle class", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_urban if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  


margins,  at(gr_urban=(0(0.1)1) comp_mpi=1 part=1) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) title("") ytitle("Development share of spending", size(large))  level(95)  xtitle("Support from urban middle class", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_urban if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  


*Social
xtreg v5_social_p c.comp_mpi##c.part##c.gr_rural c.comp_mpi##c.part##c.gr_urban c.comp_mpi##c.part##c.gr_mass v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco i.year if cow != 40 & colony != 1, fe cluster(cow) 

est store so_so2

margins,  at(gr_mass=(0(0.1)1) comp_mpi=0 part=0) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  title("") ytitle("Social share of spending", size(large))  level(95)  xtitle("Support from the masses", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_mass if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  


margins,  at(gr_mass=(0(0.1)1) comp_mpi=0.5 part=0.25) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  title("") ytitle("Social share of spending", size(large))  level(95)  xtitle("Support from the masses", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_mass if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  

margins,  at(gr_mass=(0(0.1)1) comp_mpi=1 part=1) atmeans
marginsplot,  xlabel(0 1) recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  title("") ytitle("Social share of spending", size(large))  level(95)  xtitle("Support from the masses", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
addplot(histogram gr_mass if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  



*** Appendix C5: Controlling for Other Covariates

* Table C7: considering time-heterogeneous effects of natural resources

tabulate year, generate(yd)

* Model C-19
xtreg v5_security_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop c.log_total_oil_income_pc##c.yd* e_miinterc e_miinteco  if colony !=1 & cow != 40, fe cluster(cow) 


* Model C-20
xtreg v5_admin_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop c.log_total_oil_income_pc##c.yd* e_miinterc e_miinteco  if colony !=1 & cow != 40, fe cluster(cow) 


* Model C-21
xtreg v5_development_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop c.log_total_oil_income_pc##c.yd* e_miinterc e_miinteco  if colony !=1 & cow != 40, fe cluster(cow) 


* Model C-22
xtreg v5_social_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop c.log_total_oil_income_pc##c.yd* e_miinterc e_miinteco  if colony !=1 & cow != 40, fe cluster(cow) 


* Table C8: Controlling for Battle Deaths (Both International and Civil Conflicts)

use "CPS_HM2024_replication.dta", clear


* Model C-23
xtreg v5_security_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc inter_prop_bd intra_prop_bd i.year if cow != 40 & colony != 1, fe cluster(cow) 

// Security

* Figure C5a
margins,  dydx(comp_mpi) at(part=(0(0.1)1)) atmeans
marginsplot,  recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black)) yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Security share of spending", size(large))  level(95)  xtitle("Participation", size(large)) ///
ylabel(,nogrid angle(0)) xlabel(,nogrid)  ///
addplot(histogram part if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2))  ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  

* Figure C5b
margins,  dydx(part) at(comp_mpi=(0(0.1)1)) atmeans
marginsplot,  recast(line) recastci(rline) plot1opts(lw(thick) lpattern(solid) lc(red)) ci1opts(lw(thick) lpattern(longdash) lc(black))  yline(0, lcolor(black) lpattern(dash)) title("") ytitle("Security share of spending", size(large))  level(95)  xtitle("Contestation", size(large))  ///
ylabel(,nogrid angle(0)) xlabel(,nogrid) ///
 addplot(histogram comp_mpi if e(sample)==1, fcolor(none) lcolor(gs11) yaxis(2) ytitle("", axis(2)) ylabel(none, axis(2)) legend(off))  graphregion(color(white)) bgcolor(white) 
gr_edit yaxis2.draw_view.setstyle, style(no)  

* Model C-24
xtreg v5_admin_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc inter_prop_bd intra_prop i.year if cow != 40 & colony != 1, fe cluster(cow) 

* Model C-25
xtreg v5_development_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc inter_prop_bd intra_prop i.year if cow != 40 & colony != 1, fe cluster(cow) 


* Model C-26
xtreg v5_social_p c.comp_mpi##c.part v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc inter_prop_bd intra_prop i.year if cow != 40 & colony != 1, fe cluster(cow) 


* Appendix C6: IV estimator 

* Model C-27; First-stage models for Table C10

#delimit 
ivreg2 v5_security_p v5_security_p_neighbor_mean v5_other_p total_incl_l deficit_p log_e_gdppc  log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco   
(comp_mpi part comp_part = c.comp_mpi_neighbor_mean##c.part_neighbor_mean c.l.comp_mpi_neighbor_mean##c.l.part_neighbor_mean c.l2.comp_mpi_neighbor_mean##c.l2.part_neighbor_mean c.l3.comp_mpi_neighbor_mean##c.l3.part_neighbor_mean) if colony !=1 & cow != 40, dkraay(3) savefirst first; 

#delimit cr; 

* Model C-28; First-stage models for Table C11

#delimit 
ivreg2 v5_admin_p v5_admin_p_neighbor_mean v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop log_total_oil_income_pc e_miinterc e_miinteco  
(comp_mpi part comp_part = c.comp_mpi_neighbor_mean##c.part_neighbor_mean c.l.comp_mpi_neighbor_mean##c.l.part_neighbor_mean c.l2.comp_mpi_neighbor_mean##c.l2.part_neighbor_mean c.l3.comp_mpi_neighbor_mean##c.l3.part_neighbor_mean) if colony !=1 & cow != 40, dkraay(3) savefirst first; 

#delimit cr; 


* Model C-29; First-stage models for Table C12

#delimit 
ivreg2 v5_development_p v5_development_p_neighbor_mean v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco  
(comp_mpi part comp_part = c.comp_mpi_neighbor_mean##c.part_neighbor_mean c.l.comp_mpi_neighbor_mean##c.l.part_neighbor_mean c.l2.comp_mpi_neighbor_mean##c.l2.part_neighbor_mean c.l3.comp_mpi_neighbor_mean##c.l3.part_neighbor_mean) if colony !=1 & cow != 40, dkraay(3) savefirst first; 

#delimit cr; 

* Model C-30; First-stage models for Table C13

#delimit 
ivreg2 v5_social_p v5_social_p_neighbor_mean v5_other_p total_incl_l deficit_p log_e_gdppc log_e_pop  log_total_oil_income_pc e_miinterc e_miinteco  
(comp_mpi part comp_part = c.comp_mpi_neighbor_mean##c.part_neighbor_mean c.l.comp_mpi_neighbor_mean##c.l.part_neighbor_mean c.l2.comp_mpi_neighbor_mean##c.l2.part_neighbor_mean c.l3.comp_mpi_neighbor_mean##c.l3.part_neighbor_mean) if colony !=1 & cow != 40, dkraay(3) savefirst first; 

#delimit cr; 

